﻿using Microsoft.AspNetCore.Authentication;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Identity;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using System;
using System.Collections.Generic;
using System.Security.Claims;
using System.Text;
using System.Threading.Tasks;

namespace News.CYT369.Com.Domains.Identity
{
    public class SignInManager: Microsoft.AspNetCore.Identity.SignInManager<SysUser>
    {
        public SignInManager(UserManager<SysUser> userManager,
                             IHttpContextAccessor contextAccessor,
                             IUserClaimsPrincipalFactory<SysUser> claimsFactory,
                             IOptions<IdentityOptions> optionsAccessor,
                             ILogger<SignInManager<SysUser>> logger,
                             IAuthenticationSchemeProvider schemes,
                             IUserConfirmation<SysUser> confirmation)
                            : base(userManager, contextAccessor, claimsFactory, optionsAccessor, logger, schemes, confirmation)
        {

        }

        public override Task SignInAsync(SysUser user, AuthenticationProperties authenticationProperties, string authenticationMethod = null)
        {
            return base.SignInAsync(user, authenticationProperties, authenticationMethod);
        }

        public override Task SignInAsync(SysUser user, bool isPersistent, string authenticationMethod = null)
        {
            return base.SignInAsync(user, isPersistent, authenticationMethod);
        }

        protected override Task<SignInResult> SignInOrTwoFactorAsync(SysUser user, bool isPersistent, string loginProvider = null, bool bypassTwoFactor = false)
        {
            return base.SignInOrTwoFactorAsync(user, isPersistent, loginProvider, bypassTwoFactor);
        }

        public override Task<ClaimsPrincipal> CreateUserPrincipalAsync(SysUser user)
        {
            return base.CreateUserPrincipalAsync(user);
        }

        public override Task<SignInResult> CheckPasswordSignInAsync(SysUser user, string password, bool lockoutOnFailure)
        {
            if (user != null)
            {
                return Task.FromResult(SignInResult.Success);
            }

            return Task.FromResult(SignInResult.Failed);
        }

        public override Task<SignInResult> PasswordSignInAsync(string userName, string password, bool isPersistent, bool lockoutOnFailure)
        {
            return base.PasswordSignInAsync(userName, password, isPersistent, lockoutOnFailure);
        }


    }
}
